/**
 * Created by fupeng on 17/6/22.
 */
var model = require('../models/SpreaderModel');


module.exports ={

    getView:function(req,res){
        res.render("spread",{
            title: '推广人列表',
            layout: false
        });
    },
    getSpreaderView:function(req,res){
        let params ={
            open_id:req.query.open_id
        }
        model.getSpreaderbyopenid(params,function (err,spreader) {
            if(!err){
                res.render("spreader",{
                    title: spreader.nickname,
                    layout: false,
                    spreader:spreader
                });
            }else{
                res.render('error', {
                    title: '服务器出错',
                    message:'查询推广人失败',
                    layout: false
                });
            }

        })

    },

    getSpreader:function(req,res){
        let params ={
            lastIndex:req.body.lastIndex,
            nickname:req.body.nickname
        }
        model.getSpreader(params, function(err,result){
            if(!err){
                res.json({
                    status:'success',
                    message:'success',
                    data:result
                });
            }
        });
    }


}